home *** CD-ROM | disk | FTP | other *** search
- Path: in2.uu.net!novia!usenet
- From: srwillrd@novia.net (William E. Kempf)
- Newsgroups: comp.lang.c++,comp.lang.c,comp.os.msdos.programer,comp.os.ms-windows.programmer.misc
- Subject: Re: fastest code
- Date: Mon, 08 Apr 1996 23:23:22 GMT
- Organization: Novia Internetworking <> 28.8kbps dialup; 402/390-2NET
- Message-ID: <31698acd.361838756@204.248.25.97>
- References: <316112A2.7D37@public.sta.net.cn> <31611AC9.7DE1@wight.hursley.ibm.com> <3162c21a.6084138@204.248.25.97> <31641DE2.31D4@halcyon.com> <31658942.99299605@204.248.25.97> <4k9g04$4ov@news1.mnsinc.com>
- NNTP-Posting-Host: 167.16.65.84
- X-Newsreader: Forte Agent .99e/32.201
-
- huang@mnsinc.com (Szu-Wen Huang) wrote:
-
- :William E. Kempf (srwillrd@novia.net) wrote:
- :
- :: Ok, my cutsy remark has confused several people, so I will explain.
- :: In computer science, algorithms (and this will apply to the final
- :: machine code generated by a compiler) are evaluated for speed in a
- :: system independant way, through a formula known as Big-O notation. So
- :: code is not said to be faster just because it is running on a faster
- :: machine. The executable program may be faster, but the underlying
- :: code may not be. All kinds of things can effect this, such as wether
- :: or not the compiler moves variable declarations outside of loops, etc.
- :
- :Unfortunately, the big-O analysis of algorithms do not tell you of
- :the algorithm's speed, rather, it shows the relationship between
- :input size and execution time. An O(n^2) algorithm may run faster
- :than an O(n) algorithm for all practical sizes of n.
- :
- :: The original question was looking for this kind of information (even
- :: if the poster does not understand Big-O, which I don't know if he did
- :: or not). He wants to know what compiler will best optimize the
- :: machine language code generated for a specific OS and computer
- :: architecture.
- :
- :Optimizations have little to do with time complexities as well. A
- :compiler today is not likely to change an O(n^2) algorithm into an
- :O(n) algorithm simply by optimizing the code, though an O(n) algorithm
- :might be optimized into an O(1) algorithm if you're talking about a
- :truly dumb programmer ;).
-
- Point taken. That's the second time I've stated something in the
- Usenet in as many days that is incorrect (or incomplete). In both
- cases I should have known better, but didn't think things through.
-
- Oh well, math is not my strong suit, and Big-O give me no end of
- problems well getting my degree...
-
- -----
- William E. Kempf : http://www.novia.net/~srwillrd
- "Sir Willard" : mailto:srwillrd@novia.net (home)
- Knight of the Ascii Table : mailto:wekempf@marlton.1dc.com (work)
-